package org.itest.httpclient.service.controller;

import lombok.extern.log4j.Log4j;
import org.itest.httpclient.service.util.HttpClientUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sunxinhe
 */
@RestController
@Log4j
public class ClientController {

    @GetMapping("/client/")
    public String client(@RequestParam String url) {
        String ret = null;
        try {
            ret = HttpClientUtils.doGet(url);
        } catch (Exception e) {
            ret = "Failed";
            log.error("query failed", e);
        }

        return ret;
    }
}
